// pages/map/map.js
Page({
  data: {
    latitude: 39.916527,
    longitude: 116.397128,
    scale: 10,
    markers: [{
      id: 1,
      latitude: 39.916527,
      longitude: 116.397128,
      name: '天安门'
    }]
  },

  onLoad: function () {
    // 获取当前位置
    wx.getLocation({
      type: 'gcj02',
      success: (res) => {
        this.setData({
          latitude: res.latitude,
          longitude: res.longitude
        });
      }
    });
  },

  // 地图缩放
  onRegionChange: function (e) {
    if (e.type === 'end' && e.causedBy === 'scale') {
      this.setData({
        scale: e.scale
      });
    }
  }
});